const Router=require('koa-router')
const {userValidator,verifyUser,crpytPassword,verifyLogin}=require('../middleware/user.middleware')
const {register,login,changePassword}=require('../controller/user.controller')
const { auth } = require('../middleware/auth.middleware')

const router=new Router({prefix:'/users'})

//注册接口
router.post('/register',userValidator,verifyUser,crpytPassword,register)

//登录接口
router.post('/login',userValidator,verifyLogin,login)

//修改密码接口
router.patch('/',auth,crpytPassword,changePassword)


router.get('/',(ctx)=>{
    ctx.header('Access-Control-Allow-Origin',"*")
    console.log("users");
    ctx.body='usersaa'
    return "use"
}
)

module.exports=router